package com.winse.java.javasource;

import java.util.ArrayList;
import java.util.List;

/**
 * Different types of source code for classifying characters in the raw text.
 * 
 * @author Markus Gebhard
 */
public class JavaSourceType {
	private static final List<JavaSourceType> ALL = new ArrayList<JavaSourceType>();

	private static int idCounter = 0;

	public final static JavaSourceType BACKGROUND = new JavaSourceType("Background");

	// Not really a Javasource type, but useful for conversion output options
	public final static JavaSourceType LINE_NUMBERS = new JavaSourceType("Line numbers");

	public final static JavaSourceType COMMENT_BLOCK = new JavaSourceType("Multi-line comments"); // green

	public final static JavaSourceType COMMENT_LINE = new JavaSourceType("Single-line comments"); // green

	public final static JavaSourceType KEYWORD = new JavaSourceType("Keywords");

	public final static JavaSourceType STRING = new JavaSourceType("Strings"); // darker // red

	public final static JavaSourceType CHAR_CONSTANT = new JavaSourceType("Character constants"); // dark // red

	public final static JavaSourceType NUM_CONSTANT = new JavaSourceType("Numeric constants"); // dark // red

	public final static JavaSourceType PARENTHESIS = new JavaSourceType("Parenthesis");

	public final static JavaSourceType CODE_TYPE = new JavaSourceType("Primitive Types");

	public final static JavaSourceType CODE = new JavaSourceType("Others");

	public final static JavaSourceType JAVADOC_KEYWORD = new JavaSourceType("Javadoc keywords"); // dark // green

	public final static JavaSourceType JAVADOC_HTML_TAG = new JavaSourceType("Javadoc HTML tags");

	public final static JavaSourceType JAVADOC_LINKS = new JavaSourceType("Javadoc links");

	public final static JavaSourceType JAVADOC = new JavaSourceType("Javadoc others"); // green

	public final static JavaSourceType UNDEFINED = new JavaSourceType("Undefined");

	public static final JavaSourceType ANNOTATION = new JavaSourceType("Annotation");

	public static JavaSourceType[] getAll() {
		return (JavaSourceType[]) ALL.toArray(new JavaSourceType[ALL.size()]);
	}

	private String name;
	private int id;

	/**
	 * @param name
	 *            The name of the type
	 */
	private JavaSourceType(String name) {
		this.id = idCounter++;
		this.name = name;
		ALL.add(this);
	}

	public String getName() {
		return toString();
	}

	public int getID() {
		return id;
	}

	public String toString() {
		return name;
	}
}